package com.arpa.wms.controller.wms;

import com.arpa.core.web.Result;
import com.arpa.ntocc.common.common.util.ValidateUtil;
import com.arpa.wms.service.IListTrendService;
import io.swagger.annotations.*;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 *
 * @Title 可视化数据 Controller
 *
 * @ClassName TableBackupConfigController
 * @Author HSL_WITHER
 * @Date 2021_06_09
 * @version 1.1.210609
 *
 */
@Api(tags = "可视化数据")
@RestController
@RequestMapping(value="/visual", produces = "application/json;charset=UTF-8")
@Log4j2
@Component
public class ApiVisualController {

    @Autowired
    private IListTrendService iListTrendService;

    @ApiOperation(value = "可视化单量趋势数据源", notes = "可视化单量趋势数据源")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "授权token", required = true, paramType = "header", dataType = "String", defaultValue = "Bearer 123456"),
            @ApiImplicitParam(name = "deviceId", value = "设备id", paramType = "header", dataType = "string", defaultValue = "0000000000")
    })
    @ApiResponses(@ApiResponse(code = 0, message = "success"))
    @GetMapping(value = "/timingTrend")
    public Result timingTrend(String jobNow, String jobValid) {
        // 校验job请求是否合法
        ValidateUtil.xxlJobValid(jobNow, jobValid);
        try {
            iListTrendService.inboundTimingTrend();
            iListTrendService.outboundTimingTrend();
            iListTrendService.cancelTimingTrend();
            return Result.ok();
        } catch (Exception e) {
            log.error("数据异常", e);
            return Result.error(e.getMessage());
        }
    }



    /**
     * 单量趋势统计
     *
     * @return
     */
    @ApiOperation(value = "单量趋势统计", notes = "单量趋势统计")
    @GetMapping("/listQuantityTrend")
    public Result listQuantityTrend(){
        return Result.ok().data(iListTrendService.processingData());
    }
}
